home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Graphics 3D / RaveContextSample / Source / Menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.9 KB  |  187 lines  |  [TEXT/CWIE]

  1. /****************************/
  2. /*        MENUS             */
  3. /****************************/
  4.  
  5.  
  6. /***************/
  7. /* EXTERNALS   */
  8. /***************/
  9. #include <ToolUtils.h>
  10. #include <Devices.h>
  11.  
  12. #include "mymenus.h"
  13. #include "misc.h"
  14. #include "process.h"
  15.  
  16. extern    QD3DSetupOutputType    gModelViewInfo;
  17.  
  18.  
  19. /******************/
  20. /*  PROTOTYPES    */
  21. /******************/
  22.  
  23. static void HandleSpecialMenuChoice(short theItem);
  24.  
  25.  
  26. /****************************/
  27. /*    CONSTANTS             */
  28. /****************************/
  29.  
  30.                                     // MENU BAR ITEMS //
  31. #define    NOT_A_NORMAL_MENU    -1
  32. #define    APPLE_MENU_ID        400
  33. #define    FILE_MENU_ID        401
  34. #define EDIT_MENU_ID        402
  35.  
  36.  
  37.                                     // EDIT MENU ITEMS //
  38.                                     
  39. enum
  40. {
  41.     UNDO_ITEM    =    1,
  42.     CUT_ITEM    =    3,
  43.     COPY_ITEM    =    4,    
  44.     PASTE_ITEM    =    5,
  45.     CLEAR_ITEM    =    6
  46. };
  47.  
  48.                                     // FILE MENU ITEMS //
  49. enum
  50. {
  51.     QUIT_ITEM    = 1
  52. };
  53.  
  54.  
  55.                                     // APPLE MENU ITEMS //
  56. enum                                    
  57. {                                    
  58.     ABOUT_ITEM = 1,
  59.     HELP_ITEM = 2
  60. };
  61.  
  62.  
  63.  
  64. /**********************/
  65. /*     VARIABLES      */
  66. /**********************/
  67.  
  68. MenuHandle    gAppleMenu;
  69.  
  70.  
  71. /******************/
  72. /* INIT MENU BAR  */
  73. /******************/
  74.  
  75. void InitMenuBar(void)
  76. {
  77. Handle    myMenuBar;
  78.         
  79.                     /* ALLOCATE MAIN MENU BAR */
  80.     
  81.     if ((myMenuBar    =    GetNewMBar(400)) == nil)
  82.             DoFatalAlert("\pWhered the menu bar go?!");;
  83.     SetMenuBar(myMenuBar);
  84.     
  85.                     /* SET APPLE MENU */
  86.  
  87.     if ((gAppleMenu    =    GetMenuHandle(400)) == nil)
  88.             DoFatalAlert("\pGetMHandle failed!");
  89.     AppendResMenu (gAppleMenu, 'DRVR');                        // APPEND DESK ACCESSORIES
  90.     
  91.     DrawMenuBar();
  92. }
  93.  
  94.  
  95. /***************************/
  96. /* HANDLE MENU BAR CHOICE  */
  97. /***************************/
  98.  
  99. void HandleMenuChoice(long menuChoice)
  100. {
  101. short    theMenu;
  102. short    theItem;
  103.         
  104.     if    (menuChoice != 0)
  105.     {
  106.         theMenu    =    HiWord(menuChoice);
  107.         theItem    =    LoWord(menuChoice);
  108.         switch    (theMenu)
  109.         {
  110.             case    APPLE_MENU_ID:
  111.                     HandleAppleChoice(theItem);
  112.                     break;
  113.                     
  114.             case    FILE_MENU_ID:
  115.                     HandleFileChoice(theItem);
  116.                     break;
  117.                     
  118.             case    EDIT_MENU_ID:
  119.                     HandleEditChoice(theItem);
  120.                     break;
  121.                     
  122.                     
  123.         }
  124.         HiliteMenu(0);
  125.     }
  126. }
  127.  
  128.  
  129. /*****************************/
  130. /* HANDLE APPLE MENU CHOICE  */
  131. /*****************************/
  132.  
  133. void HandleAppleChoice(short theItem)
  134. {
  135. Str255    accName;
  136. short        accNumber;
  137.         
  138.     switch    (theItem)
  139.     {
  140.         case    ABOUT_ITEM:
  141.         
  142.                 Alert(402,nil);
  143.                 break;
  144.         case    HELP_ITEM:
  145.                 Alert(128,nil);
  146.                 break;
  147.             
  148.         default:
  149.                 GetMenuItemText(gAppleMenu,theItem,accName);
  150.                 accNumber    =    OpenDeskAcc(accName);
  151.                 break;
  152.     }
  153. }
  154.  
  155. /****************************/
  156. /* HANDLE FILE MENU CHOICE  */
  157. /****************************/
  158.  
  159. void HandleFileChoice(short theItem)
  160. {
  161.     switch(theItem)
  162.     {
  163.         case    QUIT_ITEM:
  164.                 QD3D_DisposeWindowSetup(&gModelViewInfo);
  165.                 DisposeWindow(gModelViewInfo.window);
  166.                 CleanupTest();
  167.                 CleanQuit();
  168.     }
  169. }
  170.  
  171.  
  172. /****************************/
  173. /* HANDLE EDIT MENU CHOICE  */
  174. /****************************/
  175.  
  176. void HandleEditChoice(short theItem)
  177. {
  178.     SystemEdit(theItem-1);
  179.         
  180.     switch(theItem)
  181.     {
  182.     }
  183. }
  184.  
  185.  
  186.  
  187.